package eddie;

import java.util.ArrayList;

/**
 *
 * @author Eddie
 */
public class Main {

    private static ArrayList<Game> gameArray = new ArrayList();
    
    public static void main(String[] args){
        FileOpener.getInstance().getGamesFromFile();
        Visual.getInstance().setVisible(true);
        shutdownHook();
    }
    
    
    

    public static void addToArray(Game game) {
        gameArray.add(game);
    }

    public static int getGameArraySize() {
        return gameArray.size();
    }

    public static Game getGame(int position) {
        return gameArray.get(position);
    }
    
    public static void removeGame(Game game) {
        gameArray.remove(game);
    }
    
    public static int indexOfGame(Game game){
        return gameArray.indexOf(game);
    }

    static void shutdownHook() {
        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
            @Override
            public void run() {
                FileOpener.getInstance().writeGamesToFile();
                System.out.println("SAVING...");
            }
        }));
    }
}
